package com.android.baselibrary.utils

import android.app.Activity
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider


/**
 * @author: Mr.You
 * @create: 2023-09-27 13:06
 * @description:
 **/
/**
 * 控件上次点击时间
 */
private var lastClickTime: Long = 0
fun <T> View.onRepeatClickListener(millisecond:Int = 500000000,body:()-> T){
    this.setOnClickListener {
        val curClickTime = System.nanoTime()
        val interval = curClickTime - lastClickTime
        if (interval in 1 until millisecond) {
           return@setOnClickListener
        }
        lastClickTime = curClickTime
        body()
    }
}


